#include <stdio.h>
#include <stdlib.h>

#include "tab_dyn_id.h"

#include "constantes_et_macros.h"


void init_tab_dyn_id(struct tab_dyn_id* tab, const unsigned int taille)
{
    if(taille > 0)
    {
        if(!(tab->tab = (unsigned int*)malloc(taille * sizeof(unsigned int))))
            exit(EXIT_MALLOC);
    }
    else
        tab->tab = NULL;
    tab->nb_elements = 0;
}


void detruire_tab_dyn_id(struct tab_dyn_id* tab)
{
    if(tab->nb_elements > 0)
    {
        free(tab->tab);
        tab->nb_elements = 0;
    }
}



void ajouter_id(struct tab_dyn_id* tab, const unsigned int id)
{
    tab->tab[tab->nb_elements] = id;
    tab->nb_elements++;
}
